#!/bin/bash
#功能描述：同步当前目录下的git项目的develop分支

echo `date`
echo "==================="
echo "开始同步git仓库代码"
echo "==================="
for dir in $(find . -maxdepth 2 -type d |grep ".git")
do
#项目git基目录
project_git_dir=${dir#./}
#项目基本命令
git_base_cmd="git --git-dir=$project_git_dir"
#项目名称
project_name=${project_git_dir%/.git}
echo "项目名称:$project_name"
echo "项目git目录:$project_git_dir"
$git_base_cmd fetch
$git_base_cmd --work-tree=$project_name checkout develop
$git_base_cmd --work-tree=$project_name pull
done

echo "==================="
echo "同步git仓库代码完成"
echo "==================="
